import { http } from "@/utils/http";
import { adminUrlApi } from "@/utils/http/utils";

import type { Result, ResultTable } from "@/utils/http/utils";

/** 数据-数据字典类型 */
export const getDictList = (data?: object) => {
  return http.request<ResultTable>("get", adminUrlApi("dict/getTypePageList"), {
    data
  });
};

export const addDict = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/typeCreate"), {
    data
  });
};

export const editDict = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/typeUpdate"), {
    data
  });
};

export const resetDict = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/typeReset"), {
    data
  });
};

export const delDict = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/typeDelete"), {
    data
  });
};


/** 数据-数据库表 */
export const getMaintainList = (data?: object) => {
  return http.request<ResultTable>(
    "get",
    adminUrlApi("admin/dataMaintain/index"),
    {
      data
    }
  );
};

/** 数据-数据字典数据 */
export const getDictDataList = (data?: object) => {
  return http.request<ResultTable>(
    "get",
    adminUrlApi("dict/getDataPageList"),
    {
      data
    }
  );
};

/** 数据-数据字典数据 */
export const getDict = (data?: object) => {
  return http.request<Result>("get", adminUrlApi("dict/getList"), {
    data
  });
};

export const addDictData = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/dataCreate"), {
    data
  });
};

export const editDictData = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/dataUpdate"), {
    data
  });
};

export const resetDictData = (data?: object) => {
  return http.request<Result>(
    "post",
    adminUrlApi("dict/dataReset"),
    {
      data
    }
  );
};

export const delDictData = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("dict/dataDelete"), {
    data
  });
};

/** 数据-附件 */
export const getAttachDataList = (data?: object) => {
  return http.request<ResultTable>(
    "get",
    adminUrlApi("uploadFile/getPageList"),
    {
      data
    }
  );
};

export const delAttachData = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("uploadFile/delete"), {
    data
  });
};

export const downloadAttachData = (data?: object) => {
  return http.request<Result>(
    "get",
    adminUrlApi("admin/dataAttach/download"),
    {
      data
    },
    {
      responseType: "blob"
    }
  );
};

/** 日志 */

export const getOperaLog = (data?: object) => {
  return http.request<ResultTable>("get", adminUrlApi("operLog/getPageList"), {
    data
  });
};

export const operaLogDetail = (data?: object) => {
  return http.request<Result>(
    "get",
    adminUrlApi("operLog/detail"),
    {
      data
    }
  );
};

export const delOperaLog = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("operLog/delete"), {
    data
  });
};

/** 登录日志 */
export const getLoginLog = (data?: object) => {
  return http.request<ResultTable>(
    "get",
    adminUrlApi("loginLog/getPageList"),
    {
      data
    }
  );
};

export const delLoginLog = (data?: object) => {
  return http.request<Result>("post", adminUrlApi("loginLog/delete"), {
    data
  });
};
